home *** CD-ROM | disk | FTP | other *** search
/ Revista do CD-ROM 101 / CD-ROM 101.iso / compl / maya5ple / Install_MayaPLE5_English.exe / Maya / Data1.cab / dynExecuteFieldCommands.mel < prev    next >
Encoding:
Text File  |  2003-07-17  |  3.1 KB  |  104 lines

  1. // Copyright (C) 1997-2002 Alias|Wavefront,
  2. // a division of Silicon Graphics Limited.
  3. //
  4. // The information in this file is provided for the exclusive use of the
  5. // licensees of Alias|Wavefront.  Such users have the right to use, modify,
  6. // and incorporate this code into other products for purposes authorized
  7. // by the Alias|Wavefront license agreement, without fee.
  8. //
  9. // ALIAS|WAVEFRONT DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
  10. // INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
  11. // EVENT SHALL ALIAS|WAVEFRONT BE LIABLE FOR ANY SPECIAL, INDIRECT OR
  12. // CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
  13. // DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
  14. // TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
  15. // PERFORMANCE OF THIS SOFTWARE.
  16. //
  17. //
  18. //  Alias|Wavefront Script File
  19. //  MODIFY THIS AT YOUR OWN RISK
  20. //
  21. //  Creation Date:  May, 1997
  22. //  Author:         Carol Levy
  23. //
  24. //  Description:
  25. //      dynExecuteFieldCommands executes the field command and
  26. //        ConnectDynamic commands.
  27. //
  28. //  Input Arguments():
  29. //        int $isCreate -- create or add mode
  30. //        string $fieldCmd -- the field command string (except for the selection)
  31. //
  32. //  Return Value:
  33. //      None.
  34. //
  35.  
  36. //
  37. //  ============== dynExecuteFieldCommands ==============
  38. //
  39. //  SYNOPSIS
  40. //      Execute the field command and connectDynamic command.
  41. //      If executing a "Create"/positional field command, all items in
  42. //      the selection list will be connected to the field, to be
  43. //      influenced by it.
  44. //      If executing an "Add" field command, add the field to all
  45. //      items in the selection list.
  46. //
  47. global proc dynExecuteFieldCommands(int $isCreate, string $fieldCmd)
  48. {
  49.     string $selected[] = `ls -sl`;
  50.  
  51.     if (!$isCreate && size($selected) == 0)
  52.     {
  53.         warning "Nothing is selected to add a field to.";
  54.         return;
  55.     }
  56.  
  57.     // filter out the names of any selected auxiliaries,
  58.     // because we do not want to connect a field to another field.
  59.     // The node name dynBase takes in fields, emitters, and collisions.
  60.     //
  61.     string $selectedAux[] = `ls -sl -type dynBase`;
  62.     int $ii; 
  63.     for ($ii = 0; $ii < size($selected); $ii++)
  64.     {
  65.         // search for the name of this selected item
  66.         // among the selected fields.  If we find it there,
  67.         // erase this item from the array.
  68.         //
  69.         int $jj;
  70.         for ($jj = 0; $jj < size($selectedAux); $jj++)
  71.         {    
  72.             if ($selected[$ii] == $selectedAux[$jj])
  73.             {
  74.                 $selected[$ii] = "";
  75.                 break;
  76.             }
  77.         }
  78.     }
  79.  
  80.     // Execute the field command.
  81.     //
  82.     string $fieldNames[] = evalEcho ($fieldCmd);
  83.  
  84.     // If creating a positional field, and there are objects selected,
  85.     // connect them to the new field.
  86.     //
  87.     if ($isCreate && size($selected) > 0)
  88.     {
  89.         string $connectNames = "";
  90.         for ($i = 0; $i < size($selected); $i++)
  91.         {
  92.             string $objName = $selected[$i];
  93.             if (size($objName)>0)
  94.                 $connectNames  = $connectNames + " " + $objName;
  95.         }
  96.         if (size($connectNames) > 0)
  97.         {
  98.             string $connectCmd =
  99.                 "connectDynamic -f " + $fieldNames[0] + " " + $connectNames;
  100.             evalEcho($connectCmd);
  101.         }
  102.     }
  103. }
  104.